package file;

import java.io.File;
import java.io.FileFilter;

public class Test {
    public static void main(String[] args) {
        //获取当前目录中子项名字含有字母"a"的
//        String str = "bc";
//        boolean contains = str.contains("a");
//        System.out.println("是否包含a:"+contains);

        File dir = new File(".");
        if (dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                public boolean accept(File file) {
//                    return file.getName().indexOf("a")!=-1;
                    return file.getName().contains("a");
                }
            };
            File[] subs = dir.listFiles(filter);
            for(int i=0;i<subs.length;i++){
                System.out.println(subs[i].getName());
            }

        }

    }
}
